/**
 * Created by zhanshen886 on 2019/1/18.
 */
$(function() {
	function daojishi(){
		var nowtime = new Date();
	var starttime = nowtime.setMinutes(nowtime.getMinutes() + 30);
	var nowtime = new Date();
	var time = starttime - nowtime;
	var day = parseInt(time / 1000 / 60 / 60 / 24);
	var hour = parseInt(time / 1000 / 60 / 60 % 24);
	var minute = parseInt(time / 1000 / 60 % 60);
	var seconds = parseInt(time / 1000 % 60);
		if (seconds<10) {
            seconds = "0" +seconds;
          }
		if (minute<10) {
            minute = "0" +minute;
          }
        if (hour<10) {
            hour = "0" +hour;
          }
       
	$('.timespan').text( minute + "分钟" + seconds + "秒");
	var daojishi = setInterval(function() {
		var nowtime = new Date();
		var time = starttime - nowtime;
		var day = parseInt(time / 1000 / 60 / 60 / 24);
		var hour = parseInt(time / 1000 / 60 / 60 % 24);
		var minute = parseInt(time / 1000 / 60 % 60);
		var seconds = parseInt(time / 1000 % 60);
		//$('.timespan').text(day + "天" + hour + "小时" + minute + "分钟" + seconds + "秒");
		$('.timespan').text( minute + "分钟" + seconds + "秒");
		if(hour == 0 & minute == 0 & seconds == 0) {
			clearInterval(daojishi);
			$('.cancel').show()

		}
	}, 1000);
	}
	

	function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = decodeURI(window.location.search).substr(1).match(reg);
    if (r != null) return unescape(r[2]);
    return null;
}
//	
//	var qrCodeType = getQueryString('qrCodeType');
	var couponNum = getQueryString('couponNum');
	var userId = getQueryString('userId');
//	var mobile = getQueryString('mobile');
var elecCouponName = getQueryString('elecCouponName');
var amount = getQueryString('amount');
	var address = getQueryString('address');
	var couponId = getQueryString('couponId');
	var wxCode = getQueryString('wxCode');
	var zfbCode = getQueryString('zfbCode');
	var address = getQueryString('address');
	var orderId = getQueryString('orderId');
	//couponId=101960648&qrCodeType=1&couponNum=1&userId=222&address=测试地址111&mobile=15656938898
//	var couponId = '101960648';
//	var qrCodeType = '1';
//	var couponNum = '1';
//	var userId = '222';
//	var mobile = '15656938898';
//	var address = '测试地址111';
	
			daojishi();//倒计时开始
			$('.mengpin').hide();	
			$('.scanpay2 span').html(elecCouponName)//商品名称
			$('.orderMoney').html(amount) //支付金额
			$('.orderId').html(couponId) //商品id
			$('.scanpay4').html(address) //地址
			$('.scanpay61 img').attr('src', wxCode)
			$('.scanpay62 img').attr('src', zfbCode)
			var ispaysuccess = setInterval(function() {
				$.post('http://112.29.169.12:8090/portal-wap/noLogin/internetTv_getPayResultRoll.msp', 
					{
						orderId: orderId
					},
					function(data) {
						console.log(data)
						//data.retcode == 0
						if(data.retcode == 0) {
							console.log('支付成功');
							clearInterval(ispaysuccess);
							$('.all').hide();
							$('.all1').show();
						}
					}, "json");	
			},3000)
		$('.paysuccess51 ').click(function(){
			location.href='order.html?'
		})
	

	

})